<!DOCTYPE html>
[#assign ctx=springMacroRequestContext.contextPath/]
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>在线金融产品交易平台</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="stylesheet" href="${ctx!}/statics/css/font.css">
    <link rel="stylesheet" href="${ctx!}/statics/css/login.css">
    <link rel="stylesheet" href="${ctx!}/statics/css/xadmin.css">
    <script type="text/javascript" src="${ctx}/statics/layui/layui.js"></script>
    <script src="${ctx}/statics/js/jquery-3.6.0.js"></script>
</head>
<body class="login-bg">

<div class=" login layui-anim layui-anim-up">
    <div class="message">在线金融产品交易平台账号登录</div>
    <div id="darkbannerwrap"></div>

    <form method="post" class="layui-form" >
        <div class="layui-form-item">
            <input name="username" placeholder="用户名"  type="text" lay-verify="required" class="layui-input" >
        </div>
        <div class="layui-form-item">
            <input name="password" lay-verify="required" placeholder="密码"  type="password" class="layui-input">

        </div>
        <div class="layui-form-item">
            <input value="登录" lay-submit lay-filter="login" style="width:100%;" type="button">
        </div>
        <a href="/regist">没有账户?点击这里立即注册!</a>
    </form>
</div>
<script>
    layui.use(['layer', 'form'], function () {
        var layer = layui.layer;
        var form = layui.form;


        function loginSubmit(username, password){
            $.ajaxSetup({ async: false });
            $.post("/loginVerify", {username, password}, res=>{

                switch (res.code) {
                    case 200:
                        window.location.href = res.url;
                        console.log("登录成功");
                        break;
                    case 501:
                        layer.alert(res.msg, {icon:2});
                        break;
                }
            });
        }

        form.on('submit(login)', function (data) {
            // submit login data
            var username = data.field.username;
            var password = data.field.password;
            loginSubmit(username, password);
        })
    })
</script>
</body>
</html>